#include <stdio.h>
void init(int arr[][10], int n, int m)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			scanf_s("%d", &arr[i][j]);
		}
	}
}

void panduan(int arr1[][10], int arr2[][10], int n, int m)
{
	int flag = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (arr1[i][j] != arr2[i][j])
			{
				flag++;
				break;
			}
		}
	}
	if (flag != 0)
		printf("No\n");
	else
		printf("Yes\n");
}
int main()
{
	int n, m;
	int arr1[10][10];
	int arr2[10][10];
	scanf_s("%d %d", &n, &m);
	init(arr1, n, m);
	init(arr2, n, m);
	panduan(arr1, arr2, n, m);
	return 0;
}